<template>
    <div>
        <!--<Dispatch-data  v-model="objData"/>-->
        <Dispatch-list :nav-list="navList" :obj-data="objData"/>
    </div>
</template>
<script>
    import DispatchList from './tableData/TableData.vue'

    export default {
        components: {
            DispatchList
        },
        data() {
            return {
                navList: [],
                objData: {},
                newApi: 'express/orders_statistics',
                oldApi: 'express/order_counts'
            }
        },
        computed: {
            dataRefreshDialog() {
                return this.$store.state.num;
            },
        },
        watch: {
            dataRefreshDialog: function(newValue) {
                this.getNavList();
                this.getStatisticsData();
            },
        },
        mounted() {
            this.getNavList();
            this.getStatisticsData();
        },
        methods: {
            getNavList() {
                this.$http.get('express/order/order_nav')
                    .then((response) => {
                        this.navList = response.data.data;
                    })
                    .catch((error) => {
                        if (error.response.data.msg) {
                            this.$message.error(error.response.data.msg);
                        } else {
                            this.$message.error('请求错误：' + error.response.status);
                        }
                    });
            },
            getStatisticsData() {  // 获取统计数据
                this.$http.get(this.newApi)
                    .then((response) => {
                        this.objData = response.data.data;
                    })
                    .catch((error) => {
                        if (error.response.data.msg) {
                            this.$message.error(error.response.data.msg);
                        } else {
                            this.$message.error('请求错误：' + error.response.status);
                        }
                    });
            },

        }
    }
</script>
<style lang="less">
</style>

